// Pinger Program for PCMod (SERVER)

PROG.PName = "PrinterSoft"
PROG.Author = "[GU]|ZLC|thomasfn"

function PROG:Initialize( pl )
	SendClientProgram( pl, "PrinterSoft" )
	SendClientWindow( pl, "Main" )
	
	self:PC_Changed( pl )
end

function PROG:Unload()
	
end

function PROG:Think()

end

function PROG:CommandRecieved( ply, command, args )
	local pc = ply.CurrentPC
	if (!pc) then return end
	if (command == "print") then
		local printer = pc.Data[ pc:EntIndex() ].Printer
		if (printer) then
			local txt = table.concat( args, " " )
			if (txt == "#testpage") then
				txt = "---#This is a test page, printed by " .. ply:Nick() .. ".#---"
			end
			if (string.len( txt ) > 240) then
				BeamData_String( ply, "status", "Document too big!" )
			else
				printer:PrintDocument( txt )
			end
		else
			BeamData_String( ply, "status", "No printer hardware!" )
		end
	end
	if (command == "quit") then
		UnloadProgram( ply )
	end
end

function PROG:PC_Changed( ply )
	pc = ply.CurrentPC
	if (!pc) then return end
	PData[pc:EntIndex()].LPlayer = ply
end

function PROG:PacketRecieved( packet, pc )

end